package com.xiaofu.datasource.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

import javax.sql.DataSource;


/**
 * @author luofuzhou
 * @date 2024/8/23
 * @dec 描述
 */
@Data
@Configuration
@EnableAspectJAutoProxy
public class DynamicDataSourceConfig {

    @Bean("datasourceOne")
    @ConfigurationProperties(prefix = "spring.datasource.one")
    public DataSource datasourceOne() {
        return DataSourceBuilder.create().build();
    }

    @Bean("datasourceTwo")
    @ConfigurationProperties(prefix = "spring.datasource.two")
    public DataSource datasourceTwo() {
        return DataSourceBuilder.create().build();
    }

}
